package com.example.daggerdemo01.views;

import android.content.Intent;
import android.util.Log;

import android.view.View;
import android.widget.TextView;


import com.example.daggerdemo01.R;
import com.example.daggerdemo01.application.MyApplication;
import com.example.daggerdemo01.base.BaseActivity;


import com.example.daggerdemo01.component.DaggerAllComponent;
import com.example.daggerdemo01.database.DBHelper;
import com.example.daggerdemo01.entity.Student;
import com.example.daggerdemo01.module.DBModule;
import com.example.daggerdemo01.module.StudentModule;

import jakarta.inject.Inject;

public class MainActivity extends BaseActivity implements View.OnClickListener {
    private TextView mText;
    @Inject
    public Student mStudent1;
    @Inject
    public DBHelper mDBHelper;
    @Inject
    public Student mStudent2;

    @Override
    public int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    public void init() {
        mText = findViewById(R.id.text);
        mText.setOnClickListener(this);
         /*DaggerAllComponent
                .builder()
                .studentModule(new StudentModule())
                .dBModule(new DBModule(this))
                .build()
                .injectMainActivity(this);*/
        ((MyApplication)getApplication()).getAllComponent().injectMainActivity(this);
        Log.d("asdf", "Main mStudent1 hash === " + mStudent1.hashCode());
        Log.d("asdf", "Main mStudent2 hash === " + mStudent2.hashCode());
        mStudent1.setStudent_code("22");
        mStudent1.setStudent_id(1);
        mStudent1.setStudent_name("张三四");
        mStudent1.setUsername("abcdef");
        mStudent1.setPassword("123456");
        mStudent1.setClass_name("2024");
        Log.d("asdf", "Main mStudent1 === " + mStudent1);
        mDBHelper.insertStudent(mStudent1);
        Log.d("asdf", "Main size === " + mDBHelper.selectAllStudent().size());

    }
    @Override
    public void onClick(View v) {
        Intent intent = new Intent(MainActivity.this, InfoActivity.class);
        startActivity(intent);
    }
}